package com.ithei.date.mydate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class 时间格式转换 {
    public static void main(String[] args) throws ParseException {
        //无参构造方法
        SimpleDateFormat sdf = new SimpleDateFormat();
        String format = sdf.format(new Date());
        //System.out.println(format);
        Date parse = sdf.parse(format);
        //System.out.println(parse);
        //带参构造方法
        Date date = new Date();
        SimpleDateFormat sd = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        String format1 = sd.format(date);
        //System.out.println(format1);
        Date date1 = sd.parse(format1);
        //System.out.println(date);
        SimpleDateFormat sdff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");
        String st = sdff.format(date);
        System.out.println(st);
        SimpleDateFormat sdfff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String ss="2021-6-15 14:12:44";
        Date parse1 = sdfff.parse(ss);
        System.out.println(parse1);

    }
}
